package tw.rescue.interceptor;

import tw.rescue.action.GuestBookMessageAction;
import tw.rescue.dao.GuestBookDao;
import tw.rescue.dao.impl.slim3.QueryStateHolder;
import tw.rescue.dao.impl.slim3.Slim3GuestBookDaoImpl;
import tw.rescue.slim3.model.GuestBookMessage;

import com.google.appengine.api.datastore.Key;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

@SuppressWarnings("serial")
public class DaoInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		GuestBookMessageAction action = (GuestBookMessageAction )invocation.getAction();
		GuestBookDao<Key, QueryStateHolder<GuestBookMessage>> dao = new Slim3GuestBookDaoImpl();
		action.setGuestBookDao(dao);
		return invocation.invoke();
	}

}
